<?php

class ErrorController extends Zend_Controller_Action
{
       
	public function errorAction()
	{	
		$registry = Zend_Registry::getInstance();
		$general_config = $registry->get('general_config');
		$translator = $registry->get('Zend_Translate');
		$this->view->title = $translator->translate("Error occured");
		$errors = $this->_getParam('error_handler');		
		if($general_config->debug){			
	        switch ($errors->type) {
	            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
	            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
		                // 404 error -- controller or action not found
		                $this->view->message = 'HTTP/1.1 404 Not Found';            
	                break;
	            default:               	
	            		$exception = $errors->exception;
	            		$this->view->message = str_replace("\n", "<br />", "<b>Message:</b> \n" . $exception->getMessage() . "\n <b>Stack trace:</b> \n" . $exception->getTraceAsString())	;
	                break;
	        }
		}else{
			$this->view->message = "Internal server error !!!";
		}
	}
}
?>